<template>
  <div>
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column
          prop="logisticsoption"
          label="物流类型"
          :formatter="logType"
          width="180">
      </el-table-column>
      <el-table-column
          prop="logsatisfy"
          label="满足率"
          width="180">
      </el-table-column>
      <el-table-column
          prop="logsatisfyshift"
          :formatter="shiftType"
          label="满足率变化">
      </el-table-column>
      <el-table-column
          prop="price"
          label="价格">
      </el-table-column>
      <el-table-column
          prop="priceshift"
          :formatter="shiftType"
          label="价格变化">
      </el-table-column>
      <el-table-column
          prop="logchange"
          label="变动原因">
      </el-table-column>
      <el-table-column
          prop="creatDate"
          label="创建时间">
      </el-table-column>
      <el-table-column
          prop="state"
          :formatter="stateType"
          label="审批状态">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">审批</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "ApprovalLog",
  data() {
    return {
      tableData: [],
    }
  },
  methods:{
    logType:function (row, column, cellValue){
      if (cellValue == "1"){
        return '公路情况'
      }
      if (cellValue == "2"){
        return '铁路情况'
      }
      if (cellValue == "3"){
        return '水运情况'
      }
      if (cellValue == "4"){
        return '航运情况'
      }
      if (cellValue == "5"){
        return "其他情况"
      }
    },
    shiftType:function (row,column,cellValue){
      if (cellValue == "1"){
        return '上升'
      }
      if (cellValue == "2"){
        return '下降'
      }
      if (cellValue == "3"){
        return '不变'
      }
    },
    stateType:function (row,column,cellValue){
      if (cellValue == "1"){
        return '待审批'
      }
      if (cellValue == "2"){
        return '通过'
      }
      if (cellValue == "3"){
        return '未通过'
      }
    },
    handleClick(row) {
      alert(row.id)
      console.log(row)
      this.$router.push('/approvalLogSelect?id='+row.id)
    },
  },
  created() {
    const _this = this
    axios.get('http://localhost:8081/log/logSelect').then(function (resp){
      _this.tableData = resp.data
    })
  }
}
</script>

<style scoped>

</style>